home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 3367 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.2 KB  |  79 lines

  1. Path: pcc002.ids-scheer.de!news
  2. From: schley@ids-scheer.de (Schley Roland)
  3. Newsgroups: comp.lang.c++
  4. Subject: MSVC Big Problem with Borland dll
  5. Date: Tue, 23 Jan 1996 17:05:00 GMT
  6. Organization: IDS Prof. Scheer GmbH
  7. Message-ID: <4e3451$3bi@pcc002.ids-scheer.de>
  8. NNTP-Posting-Host: pse107.ids-scheer.de
  9. X-Newsreader: Forte Agent .99.82
  10.  
  11. I have created a DLL with Borland C++ 4.5 which does something 
  12. like this:
  13.  
  14. <<<
  15.  
  16. #include<iostream.h>
  17.  
  18. class A
  19. {
  20.   public:
  21.     void DoException();
  22. };
  23.  
  24. void A :: DoException()
  25. {
  26.   try {
  27.     throw ( long( 55 ) ); }
  28.  
  29.   catch ( long x ) {
  30.     cout << "catch " << x << "\n"; }
  31.  
  32. }
  33.  
  34. ///
  35. // the exported function
  36. ///
  37.  
  38. extern "C" {
  39.   void _export _cdecl Func1();
  40. }
  41.  
  42.  
  43. void _export _cdecl Func1()
  44. {
  45.   A a;
  46.   a.DoException();
  47. }
  48.  
  49. <<<
  50.  
  51. I have a little C++ test program that just calls the exported 
  52. function Func1() which throws the exception:
  53.  
  54. <<<
  55.  
  56. extern "C" {
  57.  
  58.   void Func1(); }
  59.  
  60.  
  61. void main()
  62. {
  63.   Func1();
  64. }
  65.  
  66. <<<
  67.  
  68. When I compile the test program with Borland C++ 4.5 the 
  69. program works as expected. 
  70. But when I compile it with MSVC 4.0 the program crashes:
  71. When the function Func1() is called in main() under the 
  72. debugger, I receive an "unhandled exception in 
  73. test.exe(KERNEL32.DLL): Access Violation."
  74.  
  75. Please help me!!
  76.  
  77. TIA Roland
  78.  
  79.